﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MB.Orm.DB;
using MB.RuleBase.Common;
using Model;
using Public.DataAccess;

namespace Business.Service
{
    public class BDCStore
    {
        public BDCStore() { }
        /// <summary>
        /// 获取第三方信息
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="total"></param>
        /// <param name="parValues"></param>
        /// <returns></returns>
        public List<DCStore> GetDCStoreInfo(int pageIndex, int pageSize, out int total, params object[] parValues)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<DCStore> lstDCThirdInfo = PagedDatabaseExcuteByXmlHelper.NewInstance.GetPagedObjectsByXml3<DCStore>
                                                ("DCDBA", "GetDCStoreInfo", pageIndex, pageSize, out total, parValues);
                return lstDCThirdInfo;
            }
        }
        /// <summary>
        /// 查询第三方名称是否存在
        /// </summary>
        /// <param name="ThirdName"></param>
        /// <returns></returns>
        public List<DCStore> GetDCStoreInfoByCode(string storeName, string thirdstoreCode)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<DCStore> lstDCThirdInfo = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<DCStore>("DCDBA", "GetDCStoreInfoByCode", storeName, thirdstoreCode);
                return lstDCThirdInfo;
            }
        }
        /// <summary>
        /// 新增修改第三方信息
        /// </summary>
        /// <param name="DCThirdInfo"></param>
        /// <returns></returns>
        public int MergeDCStoreInfo(DCStore dCStore)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQueryByEntity<DCStore>("DCDBA", "MergeDCStoreInfo", dCStore);
        }


        /// <summary>
        /// 获取前置仓门店信息
        /// </summary>
        /// <param name="seedType"></param>
        /// <returns></returns>
        public List<DCStore> GetDCDCStoreList(string defaultValue, int warehouseId, int thirdid)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<DCStore> lmSeedlist = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<DCStore>("DCDBA", "GetDCDCStoreList", thirdid, warehouseId);
                if (defaultValue != null && defaultValue != "")
                {
                    lmSeedlist.Add(new DCStore() { STOREID = 0, THIRDSTORECODE = "0", STORENAME = defaultValue });

                }
                return lmSeedlist;
            }
        }


    }
}
